const Koa = require('koa2');
const Router = require('koa-router');
const fs = require('fs');
const bodyParser = require('koa-bodyparser');

const app = new Koa();
const sumRouter = new Router();

app.use(bodyParser());

let routers = fs.readdirSync(__dirname + '/Routers');
routers.forEach(e => {
	let router = require(__dirname + '/Routers/' + e);
	sumRouter.use(
		'/' + e.replace('.js', ''),
		router.routes(),
		router.allowedMethods()
	);
});

app.use(sumRouter.routes());

app.listen(8080);
